﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Vds2465Telegrams
{
	[TestClass]
	public class UserData_41_TestConfirm_Test
	{
		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test01_Equals()
		{
			UserData_41_TestConfirm userData = new UserData_41_TestConfirm();

			{
				// completely different type - NOT equal
				object dummyObject = new object();
				Assert.IsFalse(userData.Equals(dummyObject));
			}

			{
				// different derived type
				UserData userData2Compare = new UserData_01_Priority(0x77);
				Assert.IsFalse(userData.Equals(userData2Compare));
			}

			{
				// compare with including timer variant with the same address byte value
				UserData_41_TestConfirm userData2Compare = new UserData_41_TestConfirm(eAddressExtension_2.TestMessageInterval, 513);
				Assert.IsFalse(userData.Equals(userData2Compare));
			}

			{
				// same object - equal
				UserData_41_TestConfirm userData2Compare = new UserData_41_TestConfirm();
				Assert.IsTrue(userData.Equals(userData2Compare));
			}
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test02_Equals_IncludedTimer()
		{
			UserData_41_TestConfirm userData = new UserData_41_TestConfirm(eAddressExtension_2.TestMessageInterval, 1026);

			{
				// completely different type - NOT equal
				object dummyObject = new object();
				Assert.IsFalse(userData.Equals(dummyObject));
			}

			{
				// different derived type
				UserData userData2Compare = new UserData_01_Priority(0x77);
				Assert.IsFalse(userData.Equals(userData2Compare));
			}

			{
				// same object - equal
				UserData_41_TestConfirm userData2Compare = new UserData_41_TestConfirm(userData.AddressExtension, userData.MinNextTestMessage);
				Assert.IsTrue(userData.Equals(userData2Compare));
			}

			{
				// different properties
				eAddressExtension_2 addressExtension2 = eAddressExtension_2.TestMessageInterval;
				if (userData.AddressExtension == eAddressExtension_2.TestMessageInterval)
				{
					addressExtension2 = eAddressExtension_2.TimeToNextTestMessage;
				}
				UserData_41_TestConfirm userData2Compare = new UserData_41_TestConfirm(addressExtension2, userData.MinNextTestMessage);
				Assert.IsFalse(userData.Equals(userData2Compare));
			}

			{
				// same properties but different ReportType
				UserData_41_TestConfirm userData2Compare = new UserData_41_TestConfirm(userData.AddressExtension, (UInt16) (userData.MinNextTestMessage + 1));
				Assert.IsFalse(userData.Equals(userData2Compare));
			}
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test03_GetHashCode()
		{
			{
				UserData_41_TestConfirm userData = new UserData_41_TestConfirm(eAddressExtension_2.TestMessageInterval, 1026);
				int hashCode = userData.GetHashCode();
			}

			{
				UserData_41_TestConfirm userData = new UserData_41_TestConfirm();
				int hashCode = userData.GetHashCode();
			}
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test04_ToString()
		{
			{
				UserData_41_TestConfirm userData = new UserData_41_TestConfirm(eAddressExtension_2.TestMessageInterval, 1026);
				string stringResult = userData.ToString();
				Assert.IsNotNull(stringResult);
			}

			{
				UserData_41_TestConfirm userData = new UserData_41_TestConfirm();
				string stringResult = userData.ToString();
				Assert.IsNotNull(stringResult);
			}
		}
	}
}
